home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk8
/
superlib
/
libsrc.arc
/
wildcmp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-12-22
|
788b
|
60 lines
/*
* Compare a wild card name with a normal name
*/
#defineMAXB 8
wildcmp(wild, name)
char *wild, *name;
{
register char *w = wild;
register char *n = name;
char *back[MAXB][2];
intbi = 0;
while (*n || *w) {
switch (*w) {
case '*':
if (bi == MAXB) {
puts ("Too many levels of '*'");
return (0);
}
back[bi][0]= w;
back[bi][1]= n;
++bi;
++w;
continue;
goback:
--bi;
while (bi >= 0 && *back[bi][1] == '\0')
--bi;
if (bi < 0)
return (0);
w =back[bi][0] + 1;
n =++back[bi][1];
++bi;
continue;
case '?':
if (!*n) {
if (bi)
goto goback;
return (0);
}
break;
default:
if (*n != *w) {
if (bi)
goto goback;
return (0);
}
break;
}
if (*n) ++n;
if (*w) ++w;
}
return (1);
}